home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / bbs / str_utilities3.lha / str.utils / STR.LogOn.rexx < prev    next >
OS/2 REXX Batch file  |  1994-07-18  |  5KB  |  192 lines

  1. /*
  2.  
  3.     STR.LogOn.rexx - An editable log-on manager for each user.
  4.  
  5.     Version 1.11
  6.  
  7. */
  8.  
  9. options results
  10.  
  11. if ~show('l','rexxsupport.library') then do
  12.   if ~addlib('rexxsupport.library',0,-30,0) then do
  13.     print 'RexxSupport.Library missing! Can''t continue...'
  14.     exit 10
  15.   end
  16. end
  17.  
  18. datapath = 'Doors:STR.Utils/'  /*  Path to the STR.LogOn.Mcfg file   */
  19.  
  20. runagain = 1  /*  1 = User is allowed to re-run the log-on sequence  *
  21.                *      when the program is executed as a door.        *
  22.                *  0 = Only allows user to re-edit the sequence, no   *
  23.                *      run through is allowed.                        */
  24.  
  25. mandatory = 1 /*  1 = User must create a log-on sequence.            *
  26.                *  0 = User may abort log-on manager without creating *
  27.                *      a log-on sequence.                             */
  28.  
  29. inp = 'input'
  30. out = 'output'
  31.  
  32. title = '\n2  \c6STR\c7.\c6LogOnManager \c5Program By\c7: \c2Black Fire \c6[\c2Call \c5Robotech BBS \c61-808-456-7745\c7]\n1'
  33. wait  = '\n1\c6STR\c7.\c6LogOnManager \c7- \q1Press \c7\z4 RETURN \z0\q1 to continue\c7:\g0\n2'
  34.  
  35. path 2; userpath = result
  36. getuser 40; userpath = userpath||result'/'
  37. getuser 23; node = result
  38.  
  39. getwhat node; location = result
  40.  
  41. update = 0
  42. if exists(userpath'STR.LogOn.Ucfg') then do
  43.   file1 = statef(userpath'STR.LogOn.Ucfg')
  44.   file2 = statef(datapath'STR.LogOn.Mcfg')
  45.  
  46.   day1 = word(file1,5); day2 = word(file2,5)
  47.   min1 = word(file1,6); min2 = word(file2,6)
  48.  
  49.   if (day2 > day1) then update = 1
  50.   else if (min2 > min1) & (day2 = day1) then update = 1
  51. end
  52.  
  53. bufferflush
  54.  
  55. if pos('Logon Manager',location) > 0 then do
  56.   print title
  57.   queryy '\q1Are you sure you want to re-edit your log-on sequence? (\c7Y\q1/n): '
  58.   ans = upper(result)
  59.   if ans = 'YES' then call makechoice()
  60.   if runagain = 1 then do
  61.     queryy '\q1Would you like to run through your log-on sequence now? (\c7Y\q1/n): '
  62.     ans = upper(result)
  63.     if ans = 'YES' then call douserchoice()
  64.   end
  65.   exit
  66. end
  67.  
  68. if update = 1 then do
  69.   print title
  70.   if mandatory = 1 then do
  71.     print '\q1Updating your log-on sequence is mandatory!'
  72.     ans = 'YES'
  73.   end
  74.   else do
  75.     queryy '\q1The log-on choices have changed!\n2Would you like to re-edit your sequence? (\c7Y\q1/n): '
  76.     ans = upper(result)
  77.   end
  78.   if ans = 'YES' then call makechoice()
  79.   call douserchoice()
  80.   exit
  81. end
  82.  
  83. if exists(userpath'STR.LogOn.Ucfg') then do
  84.   call douserchoice()
  85.   exit
  86. end
  87.  
  88. print title
  89. if mandatory = 1 then do
  90.   print '\q1Creation of a log-on sequence is mandatory!'
  91.   ans = 'YES'
  92. end
  93. else do
  94.   queryy '\q1You have not created your log-on sequence yet!\n2Would you like to do so now? (\c7Y\q1/n): '
  95.   ans = upper(result)
  96. end
  97. if ans = 'NO' then exit
  98. call makechoice()
  99. call douserchoice()
  100.  
  101. exit
  102.  
  103.  
  104. makechoice:
  105.  
  106. if ~exists(datapath'STR.LogOn.Mcfg') then do
  107.   print '\n1\q1Please notify the Sysop that the Log-on Manager cannot find its datafiles!\n1'
  108.   exit
  109. end
  110.  
  111. if ~open(inp,datapath'STR.LogOn.Mcfg','r') then do
  112.   logentry 'STR.LogOn.rexx cannot open "'datapath'STR.LogOn.Mcfg"!'
  113.   exit 10
  114. end
  115.  
  116. if ~open(out,userpath'STR.LogOn.Ucfg','w') then do
  117.   logentry 'STR.LogOn.rexx cannot open "'userpath'STR.LogOn.Ucfg"!'
  118.   exit 10
  119. end
  120.  
  121. desc = readln(inp)
  122. cmd  = readln(inp)
  123. line = readln(inp)
  124. do until eof(inp)
  125.   parse var line flag';'arg
  126.   if bitand(d2c(flag),'4'x) = '4'x then do
  127.     print '\n1\q1Item: "\c2'desc'\q1" is mandatory!  Adding....'
  128.     ans = 'YES'
  129.   end
  130.   else do
  131.     queryy '\n1\q1Do you want to see "\c2'desc'\q1"? (\c7Y\q1/n): '
  132.     ans = upper(result)
  133.   end
  134.   getcarrier
  135.   if result = 'FALSE' then do
  136.     call close(out)
  137.     call close(inp)
  138.     call delete(userpath'STR.LogOn.Ucfg')
  139.     exit
  140.   end
  141.   if ans = 'YES' then do
  142.     call writeln(out,desc)
  143.     call writeln(out,cmd)
  144.     call writeln(out,line)
  145.   end
  146.   desc = readln(inp); if eof(inp) then leave
  147.   cmd  = readln(inp)
  148.   line = readln(inp)
  149. end
  150. call close(out)
  151. call close(inp)
  152.  
  153. print '\n1You may re-edit your sequence at any time by running the Logon Manager.'
  154. print 'Which can be found in the Online Programs, Utilities area.'
  155. sendstring wait
  156.  
  157. return
  158.  
  159.  
  160. douserchoice:
  161.  
  162. file1 = statef(userpath'STR.LogOn.Ucfg')
  163. if word(file1,2) = 0 then return
  164.  
  165. if ~open(inp,userpath'STR.LogOn.Ucfg','r') then do
  166.   logentry 'STR.LogOn.rexx cannot open "'userpath'STR.LogOn.Ucfg"!'
  167.   exit 10
  168. end
  169.  
  170. desc = readln(inp)
  171. cmd  = readln(inp)
  172. line = readln(inp)
  173. do until eof(inp)
  174.   parse var line flag';'arg
  175.   if bitand(d2c(flag),'1'x) = '1'x then sendstring d2c(12)
  176.   if bitand(d2c(flag),'8'x) = '8'x then address command 'Echo >T:RexxArg'node' "'arg'"'
  177.   sendstring cmd
  178.   getcarrier
  179.   if result = 'FALSE' then do
  180.     call close(inp)
  181.     return
  182.   end
  183.   if bitand(d2c(flag),'2'x) = '2'x then sendstring wait
  184.   call delete('T:RexxArg'node)
  185.   desc = readln(inp); if eof(inp) then leave
  186.   cmd  = readln(inp)
  187.   line = readln(inp)
  188. end
  189. call close(inp)
  190.  
  191. return
  192.